const http = require('http')
const app = http.createServer()
const fs = require('fs')
const path = require('path')
app.on('request', (req, res) => {
    if (req.url == '/index.html') {
        // res.setHeader('Content-Type','text/html;charset=utf-8')
        // res.end('好好好')
        console.log(req.method)
        fs.readFile(path.join(__dirname, 'index.html'), (err, data) => {
            // console.log(data.toString())
            res.end(data.toString())
        })
    } else {
        res.end('地址不匹配')
    }
    // res.end('hhh')
})
//中间可以添加一个参数为IP地址
app.listen('3000', () => {

})